﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace homework9
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Type personType = typeof(Person);
            ConstructorInfo constructor = personType.GetConstructor(new[] { typeof(string), typeof(int) });
            if(constructor!=null)
            {
                object[] parameters = { "Abc", 100 };
                Person person = (Person)constructor.Invoke(parameters);
                Console.WriteLine($"Name:{person.Name},Age:{person.Age}");
            }
            else
            {
                Console.WriteLine("未找到合适的构造函数");
            }
            Console.ReadKey();
        }
        class Person
        {
            public string Name { get; set; }
            public int Age { get; set; }
            public Person(string name ,int age)
            {
                Name = name;
                Age = age;
            }
        }
    }
}
